#pragma once
#include "Aquarium.h"

using namespace std;

Aquarium Aquarium::aquariumSingleton;

Aquarium::Aquarium(){
}


// static method declaration
Aquarium& Aquarium::getAquarium(){
	return Aquarium::aquariumSingleton;
}


void Aquarium::addFish(FishFactory::FISH_TYPE impl, Point& speed, const Point& location, bool transparent, int size){
	Fish* newFish = new Fish();
	newFish->create(impl,speed,location,transparent,size); //create an implementation
	newFish->setSubject(&Aquarium::aquariumSingleton);
	fishVector.push_back(newFish);
}



void Aquarium::feedAquarium(){
	Aquarium::aquariumSingleton.Notify("feed");
}

void Aquarium::debugAquarium(){
	Aquarium::aquariumSingleton.Notify("debug");
}

void Aquarium::pauseAquarium(){
	Aquarium::aquariumSingleton.Notify("pause");
}

void Aquarium::removeFish(int fishID){
	for (unsigned int i = 0; i < fishVector.size(); i++){
		if (fishVector[i]->getID() == fishID){
			delete fishVector[i];
			fishVector.erase(fishVector.begin()+i);
			return;
		}
	}
}

void Aquarium::emptyAquarium(){
	// destroy each element
	for (unsigned int i = 0; i < fishVector.size(); i++){
		delete fishVector[i];
	}
	// clear the vector
	fishVector.clear();
}